package com.supreme.basicserver.controller;

import com.supreme.basicserver.mapper.mybatis.MBTestMapper;
import com.supreme.commonentity.mysql.primary.MBTest;
import com.supreme.commonboot.utils.AjaxResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "test")
public class TestController {

    private final MBTestMapper mbTestMapper;

    @Autowired
    public TestController(MBTestMapper mbTestMapper) {
        this.mbTestMapper = mbTestMapper;
    }

    @GetMapping(value = "hello")
    public AjaxResp hello() {
        return new AjaxResp();
    }

    @GetMapping(value = "searchAll")
    public AjaxResp searchTestAll() {
        List<MBTest> testList = this.mbTestMapper.selectList(null);
        return new AjaxResp(testList);
    }

    @PostMapping(value = "create")
    public AjaxResp createTest(@RequestBody MBTest test) {
        int insert = this.mbTestMapper.insert(test);
        return new AjaxResp(insert);
    }
}
